#include "TextureManager.h"
TextureManager::TextureManager(void)
{
}
TextureManager::~TextureManager(void)
{
	//TODO:release all texture's resources
}
Texture* TextureManager::createOrGetTexture(std::string filename)
{
	const int length = filename.length();
	for(int i=0; i < length; ++i)
	{
		filename[i] = std::tolower(filename[i]);
	}
	std::map<std::string,Texture*>::iterator it = mChildren.find(filename);
	if (it == mChildren.end())
	{
		Texture* pTexture = new Texture(filename);
		if (!pTexture->Load())
		{
			printf("can't load texture:%s!\r\n",filename);
			return NULL;
		}
		mChildren.insert(std::pair<std::string,Texture*>(filename,pTexture));
		return pTexture;
	}else
	{
		return it->second;
	}
}

